﻿<Window x:Class="KinectAntiTheft.Login"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:local="clr-namespace:KinectAntiTheft_BL;assembly=KinectAntiTheft_BL"
        xmlns:ka="clr-namespace:KinectAntiTheft"
        Title="Login" Height="350" Width="525" 
        x:Name="this" >
  
    <Window.DataContext>
        <local:LoginViewModel />
    </Window.DataContext>
    <Window.Resources>
        <Style x:Key="errStyleLabel" TargetType="Label">
            <Setter Property="Background" Value="Red" />
            <Setter Property="FontStyle" Value="Italic" />
        </Style>
        <BooleanToVisibilityConverter x:Key="boolToVisibilityConverter" />
        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="UserRegMode">

            <ObjectDataProvider.MethodParameters>

                <x:Type TypeName="local:Mode" />

            </ObjectDataProvider.MethodParameters>

        </ObjectDataProvider>

    </Window.Resources>
    <Grid Name="MainGrid" Margin="2" >
        <Grid.RowDefinitions>
            <RowDefinition Height="64*" />
            <RowDefinition Height="55*" />
            <RowDefinition Height="63*" />
            <RowDefinition Height="58*" />
            <RowDefinition Height="67*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="107*" />
            <ColumnDefinition Width="392*"/>
        </Grid.ColumnDefinitions>
        <Label Content="UserName" Height="28" HorizontalAlignment="Left" Margin="11,2,0,0" Name="lblUserName" VerticalAlignment="Top" />
        <TextBox Grid.Column="1" Height="23" HorizontalAlignment="Left" Margin="17,7,0,0" Name="txtUserName" VerticalAlignment="Top" Width="339" 
                 Text="{Binding Path=User.UserName, Mode=TwoWay, ValidatesOnDataErrors=True,UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding Path=User.IsRegister, Converter={StaticResource boolToVisibilityConverter}}" IsReadOnly="{Binding Path=User.IsRegister}" />
        <Label Content="Password" Height="28" HorizontalAlignment="Left" Margin="11,31,0,0" Name="lblPassword" VerticalAlignment="Top" Grid.Row="1" Visibility="{Binding Path=User.IsLogin, Converter={StaticResource boolToVisibilityConverter}}" Grid.RowSpan="2" />
        
        <PasswordBox Height="23" HorizontalAlignment="Left" Margin="17,31,0,0" Name="txtPassword" VerticalAlignment="Top" Width="339" Grid.Column="1" Grid.Row="1"
                 ka:PasswordBoxAssistant.BindPassword="True"
                ka:PasswordBoxAssistant.BoundPassword="{Binding Path=User.UserPassword, Mode=TwoWay, ValidatesOnDataErrors=True,UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding Path=User.IsLogin, Converter={StaticResource boolToVisibilityConverter}}" />
        <Button Content="Save" Grid.Column="1" Grid.Row="4" Height="23" HorizontalAlignment="Left" Margin="17,32,0,0" Name="btnLogin" VerticalAlignment="Top" Width="75" CommandParameter="{Binding Path=User}" Command ="{Binding Path=LoginCommand, UpdateSourceTrigger=PropertyChanged}"/>
        <Label Grid.Column="1" Height="23" HorizontalAlignment="Left" Margin="17,5,0,0" Name="lblError" Content="{ Binding Path=Error, Mode=TwoWay}" VerticalAlignment="Top" Width="2000" Style="{StaticResource errStyleLabel}" Visibility="{Binding Path=IsError, Converter={StaticResource boolToVisibilityConverter}}" />
        <Label Content="Email" Height="28" HorizontalAlignment="Left" Margin="21,20,0,0" Name="lblEmail" VerticalAlignment="Top" Grid.Row="2" Visibility="{Binding Path=User.IsLogin, Converter={StaticResource boolToVisibilityConverter}}" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="17,25,0,0" Name="txtEmail" Text="{Binding Path=User.UserEmail, Mode=TwoWay, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="339" Grid.Column="1" Grid.Row="2" Visibility="{Binding Path=User.IsLogin, Converter={StaticResource boolToVisibilityConverter}}" />
        <Label Content="TimeOut(minutes)" Grid.Row="3" Height="33" HorizontalAlignment="Left" Margin="0,17,0,0" Name="lblTimeout" VerticalAlignment="Top" />
        <Label Content="{Binding Path=User.ApplicationGuid}" Grid.Column="1" Height="24" HorizontalAlignment="Left" Margin="17,40,0,0" Name="lblGUID" VerticalAlignment="Top" Width="339" Visibility="{Binding Path=User.IsRegister, Converter={StaticResource boolToVisibilityConverter}}" />
        <Slider Grid.Column="1" Grid.Row="3" Height="23" HorizontalAlignment="Left" Margin="27,17,0,0" Name="sldMin" VerticalAlignment="Top" Width="318" Value="{Binding Path=TimeoutMinutes}" SelectionStart="1" SmallChange="0.5" />
        <Label Content="{Binding ElementName=sldMin,Path=Value}" Grid.Column="1" Grid.Row="3" Height="28" HorizontalAlignment="Left" Margin="54,30,0,0" Name="label1" VerticalAlignment="Top" Width="118" />
    </Grid>
</Window>
